//Rational.h
#ifndef RATIONAL_H_
#define RATIONAL_H_
#include <iostream>
using namespace std;
class Rational {
private:
    int nume;//分子
    int deno;//分母
    //规范化函数
    void standardization();
public:
    //构造函数
    Rational(int n = 0, int d = 1);
    Rational(double num);
    Rational(const Rational &rational);
    //输出函数
    void myPrint();
    //各种常见的算术、逻辑、复合赋值运算符重载函数
    //算术运算符重载
    friend Rational operator+(const Rational& r1, const Rational& r2);
    friend Rational operator-(const Rational& r1, const Rational& r2);
    friend Rational operator*(const Rational& r1, const Rational& r2);
    friend Rational operator/(const Rational& r1, const Rational& r2);
    Rational& operator=(const Rational& r);
    Rational& operator+=(const Rational &r);
    Rational& operator-=(const Rational &r);
    Rational& operator*=(const Rational &r);
    Rational& operator/=(const Rational &r);
    //关系运算符
    friend bool operator<(const Rational& r1, const Rational& r2);
    friend bool operator>(const Rational& r1, const Rational& r2);
    friend bool operator==(const Rational& r1, const Rational& r2);
    //自增自减
    Rational& operator++();
    Rational operator++(int);
    Rational& operator--();
    Rational operator--(int);
    //流插入和流提取运算符函数
    friend ostream& operator<<(ostream& out, const Rational& r);
    friend istream& operator>>(istream& in, Rational& r);
};
#endif